var express = require("express");
var router = express.Router();
var orderModel = require("../../models/order/order_list");

router.post("/", function (req, res, next) {
  // console.log(req.body);
  let { openid, title, type, state, publish_time } = req.body;
  // orderModel.find({ openid, title, type, state, publish_time, },
  orderModel.find({ state },
    function (err, docs) {
      if (!err) {
        res.json({ data: docs, msg: "查询成功！", code: 200 });
      }
    }
  );
});

module.exports = router;

// let obj = {
//   openid: "",
//   contact: "",
//   state: 0,
//   type: 1,
// };

// function filterParams(obj) {
//   let newObj = {};
//   for (let key in obj) {
//     if (obj[key] !== "") {
//       newObj[key] = obj[key];
//     }
//   }
// //   console.log(newObj);
//   return newObj
// }

// filterParams(obj);

// let { openid, contact, state, type } = filterParams(obj);
// console.log(openid,contact,state,type)
// {openid}

// // 判断该属性是否存在值
// // 存在，存入新对象
// // 最后返回新对象
